fix(core): preserve an existing database default when repairing a missing config default#987
Merged
Merged
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1f50a9113e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
phernandez
added a commit
that referenced
this pull request
Jun 12, 2026
…ed project Review follow-up (codex P2 on #987): when config's default_project has no database row but the database still holds a valid default, the repair now repoints config at that surviving default — matching synchronize_projects, which treats the database default as authoritative — instead of silently stealing the default for the just-added project. Promotion of the added project remains the fallback when no usable database default exists (the fresh-config wedge from #974, and the deeper drift where the database default is unknown to config and would be deleted by reconciliation anyway). Signed-off-by: phernandez <paul@basicmachines.co>
…sing config default Follow-up to #985 (the #974 fix by @rudi193-cmd), addressing the codex P2 raised on #987: when config's default_project has no database row but the database still holds a valid default of its own, promoting the just-added project would silently steal that default. The repair now repoints config at a surviving database default — matching synchronize_projects, which treats the database default as authoritative — and promotes the added project only when no usable database default exists (no default at all, or one unknown to config, which set_default_project rejects and reconciliation deletes). Also removes an unused ProjectConfig import from the #985 regression test (strict ruff failure; CI's --fix lint masked it). Refs #974 Signed-off-by: phernandez <paul@basicmachines.co>
0321541 to
f7fa308
Compare
phernandez
added a commit
that referenced
this pull request
Jun 12, 2026
… empty projects table On a brand-new config dir, model_post_init bootstraps a 'main' default in config.json but the one-shot CLI path never runs the server-lifespan reconciliation that would create its database row, so the first read fails with a bare "Project not found: 'main'" — which reads as a broken install rather than a missing first-run step. When resolution misses and the projects table is empty, the 404 now names the setup command. Follow-up to #974/#985/#987 (which repair the default during project add but cannot help when the first action is a read). Refs #974. Signed-off-by: phernandez <paul@basicmachines.co>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Follow-up to #985 by @rudi193-cmd, which fixed the #974 fresh-config wedge by promoting the newly added project when the configured default has no database row.
This PR addresses the codex P2 raised here: in drift states where config's default is missing from the DB but the database still holds a valid default of its own, promotion would silently steal that default.
synchronize_projectstreats the database default as authoritative in exactly this state, so the repair now:set_default_projectrejects and reconciliation deletes anyway).Also removes an unused
ProjectConfigimport from the #985 regression test — a strictruff checkfailure on main that CI's--fixlint masks.Test evidence
test_add_project_preserves_existing_db_default: builds the drift state (config default missing from DB, surviving DB default present), adds a project, asserts config is repointed at the surviving default and the added project is not promoted.tests/services/test_project_service.py(41 passed) andtests/api/v2/test_project_router.pygreen, including fix: promote first project when config default missing from DB (#974) #985's promote-path tests;ruffandtyclean.Refs #974
🤖 Generated with Claude Code